<template>
	<view>
		<!--顶部导航栏-->
		<view class="uni-tab-bar">
			<scroll-view scroll-x class="uni-swiper-tab">
				<block v-for="(tabBar,index) in tabBars" :key="index">
					<view class="swiper-tab-list" :class="{'active': tabIndex==index}" @tap="toggleTab(index)">
						{{tabBar.name}}
						<view class="swiper-tab-line">
						</view>
					</view>
				</block>
			</scroll-view>
		</view>

		<!--内容区-->
		<view class="uni-tab-bar">
			<swiper :current="tabIndex" @change="tabChange" style="height: 200px;">
				<swiper-item v-for="(content,index) in contentList" :key="index">
					<view class="swiper-item">
						<div style="height: 60px;display: none;" class="display">
							<div class="img_div">
								<image style="width: 30px; height: 30px; background-color: #fff;" src="../../static/1.png"></image>
							</div>
							<div style="line-height: 60px;font-family: Arial, Helvetica, sans-serif;">
								表格布局
							</div>
						</div>
						<div class="display" style="height: 60px;">
							<div class="img_div">
								<image style="width: 50px; height: 50px;" src="../../static/1.png"></image>
							</div>
							<div style="width: 85%;">
								<div class="display">
									<div class="font_one">设置</div>
									<div class="font_two">44M</div>
								</div>
								<div class="display">
									<div class="font_one">1个进程和1个服务</div>
									<div class="font_two">16.53</div>
								</div>
							</div>
						</div>
						{{content}}
					</view>
				</swiper-item>
			</swiper>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				tabIndex: 0, //选中标签栏的序列
				contentList: [
					"电影",
					"电视剧",
					"综艺",
					"动漫",
					"儿童"
				],
				tabBars: [{
						name: '电影',
						id: '1'
					},
					{
						name: '电视剧',
						id: '2'
					},
					{
						name: '综艺',
						id: '3'
					},
					{
						name: '动漫',
						id: '4'
					},
					{
						name: '儿童',
						id: '5'
					}
				],
				swiperHeight: 0

			}
		},
		components: {

		},
		onLoad() {},
		methods: {
			toggleTab(index) {
				console.log(index)
				this.tabIndex = index
			},
			//滑动切换swiper
			tabChange(e) {
				console.log(e.detail)
				const tabIndex = e.detail.current
				this.tabIndex = tabIndex
			}
		}
	}
</script>

<style>
	/* swiper设置 */
	.swiper-tab-list {
		color: #969696;
		font-weight: bold;
	}

	.uni-tab-bar .active {
		color: #100216;
	}

	.active .swiper-tab-line {
		width: 110upx;
		margin: auto;
		border-top: 6upx solid #100216;
		border-radius: 20upx;
	}

	.uni-swiper-tab {
		border-bottom: 1upx solid #eeeeee;
	}

	/* 浮动 */
	.display {
		display: flex;
		flex-direction: row;
	}

	/* 图片设置 */
	.img_div {
		width: 14%;
		line-height: 60px;
		margin-top: 5px;
	}

	/* 第一个字体 */
	.font_one {
		width: 60%;
	}

	/* 第二个字体 */
	.font_two {
		width: 90%;
		text-align: right;
	}
</style>
